import os
from pygpu import *

filepath = os.path.abspath(__file__)
dirpath = os.path.dirname(filepath)
print(filepath, dirpath)


def small_array_test():
    a = [5, 8, 2, 9, 0, 3]
    b = [3, 0, 6, 2, 5, 2]

    gpu = GPU()
    gpu.set_program(dirpath + "/kernels/sum.cl", "sum")
    gpu.set_return(a)
    c = gpu(a, b)

    print("a =", a)
    print("b =", b)
    print("c =", c)


n = 100000000
a = np.random.rand(n)
b = np.random.rand(n)


def large_array_test():
    gpu = GPU()
    gpu.set_program(dirpath + "/kernels/sum.cl", "sum")
    gpu.set_return(a)  # tell him the return value's shape is just like a
    result = gpu(a, b)

    gpu.print_performance()


# small_array_test()
while True:
    large_array_test()
